<template>
  <span>{{text}}</span>
</template>

<script>
import { mapGetters } from 'vuex';

export default {
  name: "deliveryType",
  inheritAttrs: false,
  props: {
    typeValue: {
      type: Number | String,
      default: 0
    }
  },
  computed: {
    ...mapGetters(["deliveryTypes"]),
    text() {
      let res = "";
      if(this.typeValue) {
        res = this.deliveryMap[this.typeValue];
      }
      return res;
    }
  },
  data() {
    return { 
      deliveryMap: {}
    }
  },
  created() {
    this.deliveryTypes.forEach(item => {
      this.$set(this.deliveryMap, item.id, item.text);
    });
  }
}
</script>